package com.online.onlineshop.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * @author zihao.wang1
 * @date 2022/3/4
 */
public class ControllerUtil {
    public static void writeJson(HttpServletResponse response, String json) {
        PrintWriter pw = null;
        if(json==null){
            return;
        }
        try {
            response.setContentType("text/json;charset=utf-8");
            pw = response.getWriter();
            pw.write(json);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (pw != null) {
                pw.close();
            }
        }
    }
}
